package com.example.pages;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import static org.junit.Assert.*;

public class MoviePage extends InternalPage{

    @FindBy(xpath = "//*[@title='Remove']/ancestor::a")
    public WebElement removeMovie;

    @FindBy(xpath = "//h2")
    public WebElement nameMovie;

    public boolean isOnThisPage(){
        return nameMovie.isDisplayed();
    }
    
    
    public MoviePage whatMoviePageOpen(String movieName) {
        assertEquals("Не открылась страница редактирования фильма", movieName, nameMovie.getText());
        return MyPageFactory.getPage(driver, MoviePage.class);
    }

    public MovieListPage removeMovie() {
        removeMovie.click();
        driver.switchTo().alert().accept();
        return MyPageFactory.getPage(driver, MovieListPage.class);
    }
}
